package com.yang.commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.List;

public class SetLore implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        // 获取手中物品 然后 设置输入的文字
        Player player = (Player) sender;
        ItemStack itemInOffHand = player.getInventory().getItemInOffHand();
        ItemMeta itemMeta = itemInOffHand.getItemMeta();
        List<String> listLore = new ArrayList<>();
        listLore.add(args[0]);
        itemMeta.setLore(listLore);
        itemInOffHand.setItemMeta(itemMeta);
        return true;
    }
}
